function GetQrCode() {
    $.ajax({
        type: "Get",
        url: "//" + location.host + "/tour/qrcode/" + api.getUrlParam("prdouctId") + ".html",
        beforeSend: function() {},
        complete: function() {},
        error: function(t) {},
        success: function(t) {
            null !== t && "" !== t ? $(".erweim").find("img").attr("src", t) : callback(null)
        }
    })
}
function RouteChange(t) {
    var e = '[data-linecode="' + t + '"]';
    $(".main2_right_n2").find("div" + e).addClass("active").siblings().removeClass("active");
    var a = $(".main2_right_n2").find("div" + e).index() - 1;
    $(".main2_right_m2").eq(a + 1).addClass("active").siblings().removeClass("active");
    var i = $(".trip_nav").find('span[id="' + t + '"]')
      , n = i.parent();
    $(".trip_nav .li").prepend(i),
    $(".trip_nav .li").attr("data-sort", $(".trip_nav .li").find("span").attr("route-data")),
    n.prepend($(".trip_nav .li").find("span").eq(1)),
    n.attr("data-sort", n.find("span").attr("route-data")),
    $(".trip_nav .li1").sortElements(function(t, e) {
        return $(t).attr("data-sort") > $(e).attr("data-sort") ? 1 : -1
    }),
    $(".main2_right_m2_nav .route_menu").eq(a).addClass("curr").siblings().removeClass("curr"),
    $(".main2_right_m2_nav .route_menu").eq(a).show().siblings(".main2_right_m2_nav .route_menu").hide(),
    $(".main2_right_m2_nav .route_menu").eq(a).find("li").eq(0).addClass("active"),
    activityDetailsHeightInit(),
    stroke = $(".main2_right_m2.active").find(".main2_right_m3_m.stroke")
}
function CheckStock(t) {
    var e = parseInt($("#adultNum").val());
    e <= 0 && $("#adultNum").val(1);
    var a = parseInt($("#childNum").val());
    a <= 0 && $("#childNum").val(0);
    var i = parseInt($(".selected_m .active").attr("data-freenum"))
      , n = e + a;
    return t ? n = parseInt(n) + 1 : n -= 1,
    i < n ? ($(".num .lack").css("display", "inline"),
    !1) : ($(".num .lack").css("display", "none"),
    !("请选择出团日期" === $(".selected .li").html() && (setTimeout(function() {
        $(".main_right3 .select .select_left .selected").addClass("active")
    }, 100),
    setTimeout(function() {
        $(".main_right3 .select .select_left .selected").removeClass("active")
    }, 300),
    setTimeout(function() {
        $(".main_right3 .select .select_left .selected").addClass("active")
    }, 500),
    setTimeout(function() {
        $(".main_right3 .select .select_left .selected").removeClass("active")
    }, 700),
    !t)))
}
function getProductInfo() {
    var t = JSON.stringify({
        ProCode: api.getUrlParam("prdouctId")
    });
    api.post("http://tourlogic.uzai.com/api/Product/GetProductInfo", t, function(t) {
        if (null !== t && 200 === t.ErrorCode) {
            if ("" === t.JsonResult || "null" === t.JsonResult)
                return $(".n1").html("已下架"),
                $(".n3").html("").hide(),
                $(".dwzx").html("咨询相似产品").show(),
                void $(".submit").hide();
            var e = JSON.parse(t.JsonResult);
            "邮轮" === e.ProductType && (location.href = "//cruise.uzai.com/cruise/" + api.getUrlParam("prdouctId") + ".html");
            var a = new Array("日","一","二","三","四","五","六")
              , i = new Date(e.GoDate).getDay()
              , n = "最低价 " + parseISO8601(e.GoDate).Format("MM-dd") + " 周" + a[i] + "出发 ，<span>¥" + e.MinPrice + "元</span>/人";
            $(".main_right1_m2").find("p").eq(0).html(n)
        }
    })
}
function IsCollectProduct() {
    var t = JSON.stringify({
        UserId: api.getCookie("user"),
        ProductId: api.getUrlParam("prdouctId")
    });
    api.post("http://tourlogic.uzai.com/api/Product/IsCollectProduct", t, function(t) {
        null !== t && 200 === t.ErrorCode && (parseInt(t.JsonResult) > 0 ? ($(".collection").addClass("active"),
        $(".collection").find("span").text("已收藏"),
        $("#collectionId").val(t.JsonResult)) : ($(".collection").removeClass("active"),
        $(".collection").find("span").text("收藏")))
    })
}
function CollectProduct(t, e) {
    var a = null;
    a = t ? JSON.stringify({
        CoId: $("#collectionId").val()
    }) : JSON.stringify({
        UserId: api.getCookie("user"),
        ProductId: api.getUrlParam("prdouctId"),
        ImgUrl: $(".main_left_rotater").find("img")[0].currentSrc,
        ProductName: $.trim($(".main .title").text()),
        MinPrice: $("#prcie").text(),
        StartCity: $("#startcity").val(),
        ProductLink: location.href
    }),
    api.post("http://tourlogic.uzai.com/api/Product/CollectProduct", a, function(t) {
        null !== t && 200 === t.ErrorCode && e(parseInt(t.JsonResult))
    })
}
function CalendarData() {
    var t = JSON.stringify({
        ProCode: api.getUrlParam("prdouctId"),
        LineSource: $.trim($("#lineSource").val())
    });
    api.post("http://tourlogic.uzai.com/api/Product/GetAllPriceCalendar", t, function(t) {
        if (null !== t && 200 === t.ErrorCode) {
            var e = ""
              , a = JSON.parse(t.JsonResult);
            if ($.isEmptyObject(a))
                return;
            for (globalCalendarData = JSON.parse(t.JsonResult),
            i = 0; i < 1; i++)
                $("#price").text(globalCalendarData[i].ProMinPrice),
                globalCalendarData[i].PreferentialAmount > 0 && $(".main_right1 n2").html("已省" + globalCalendarData[i].PreferentialAmount);
            var n = 0;
            for (i = 0; i < a.length; i++)
                a[i].IsShow ? (n = i,
                e += '<div class="li active swiper-slide" data-index="' + i + '" data-date="' + a[i].CurrentMonth + '">') : e += '<div class="li swiper-slide" data-index="' + i + '" data-date="' + a[i].CurrentMonth + '">',
                e += "<p>" + a[i].CurrentMonth + "</p>",
                0 === a[i].MonthMinPrice ? e += '<span class="no">无团期</span></div>' : -1 === a[i].MonthMinPrice ? e += '<span class="no">无团期</span></div>' : e += "<span>¥" + a[i].MonthMinPrice + "起</span></div>";
            $(".swiper-wrapper").html(e),
            $(".calendar").html(" "),
            a.length > 0 ? calendar(a[n].CurrentMonth, ".calendar") : calendar(year + "-" + mon, ".calendar"),
            TourDateData(JSON.parse(t.JsonResult), n),
            $(".calendar_t_m .li").on("click", function() {
                var e = $(this).attr("data-date");
                $(".calendar").html(" "),
                calendar(e, ".calendar");
                var a = $(this).attr("data-index");
                TourDateData(JSON.parse(t.JsonResult), a),
                $(this).addClass("active").siblings().removeClass("active")
            }),
            mySwiper1 = new Swiper(".swiper-container1",{
                slidesPerView: 5
            }),
            $(".calendar_t .icon-zuobian").click(function() {
                mySwiper1.swipePrev()
            }),
            $(".calendar_t .icon-youbian").click(function() {
                mySwiper1.swipeNext()
            }),
            ChooseTourList(JSON.parse(t.JsonResult))
        }
    })
}
function StockShowReg(t) {
    return (t = parseInt(t)) > 9 ? "充足" : 0 === t ? "余位:0" : t < 0 ? "余位:0" : t.toString()
}
function TourDateData(t, e) {
    var a = t[0].DayList;
    if (void 0 !== e && "" !== e && (a = t[e].DayList),
    null !== a) {
        var i = new Array;
        for (a.sort(function(t, e) {
            return t.Date < e.Date ? -1 : 1
        }),
        j = 0; j < a.length; j++) {
            var r = new Object;
            r.TourDateText = a[j].Date;
            var o = a[j].TeamList;
            if (r.spare = StockShowReg(o[0].FreeNum),
            r.style = $("#" + a[j].LineCode).attr("route-data"),
            r.MinPrice = o[0].MinPrice,
            r.TuanNo = o[0].TuanNo,
            i.length > 0) {
                var s = !1;
                for (n = 0; n < i.length; n++)
                    i[n].TourDateText === r.TourDateText && i[n].MinPrice < r.MinPrice && (s = !0);
                s || i.push(r)
            } else
                i.push(r)
        }
        for (var l = 0; l < i.length; l++) {
            i.sort(by("MinPrice", by("TuanNo"))),
            i.reverse();
            var c = '[data-time="' + parseISO8601(i[l].TourDateText).Format("yyyy-M-d") + '"]'
              , d = "¥" + i[l].MinPrice + "起"
              , u = ""
              , m = "";
            "余位:0" === i[l].spare ? (u = i[l].spare,
            $(c).find(".spare").parent().addClass("gray")) : (u = "余位:" + i[l].spare,
            m = i[l].style + "行程"),
            $(c).find(".price").text(d),
            $(c).find(".spare").text(u),
            $(c).find(".style").text(m),
            $(c).find('div[data-date="' + i[l].TourDateText + '"]').length > 0 ? ($(c).find('div[data-date="' + i[l].TourDateText + '"]').attr("id", i[l].TuanNo),
            $(c).find('div[data-date="' + i[l].TourDateText + '"]').html(i[l].TuanNo)) : $(c).append('<div style="display:none" data-date="' + i[l].TourDateText + '" class="tuanno" id="' + i[l].TuanNo + '">' + i[l].TuanNo + "</div>")
        }
        $(".day-list").find("li").each(function() {
            if ("" !== $(this).find(".price").html() && void 0 !== $(this).find(".price").html()) {
                for (var e = '<div class="targetBox">', a = 0; a < t.length; a++) {
                    for (var i = globalCalendarData[a].DayList, n = 0; n < i.length; n++) {
                        var r = i[n].Date.replace("-", "").replace("-", "")
                          , o = $("#" + i[n].LineCode).attr("route-data");
                        i[n].dataroute = r + o
                    }
                    if (i.sort(by("dataroute", by("ShortTuanNo"))),
                    null !== i)
                        for (j = 0; j < i.length; j++)
                            if ($(this).attr("data-time") === parseISO8601(i[j].Date).Format("yyyy-M-d") && i[j].TeamList.length > 0) {
                                var s = i[j].TeamList[0].IsShowTuanNo ? "block;" : "none;";
                                if (e += '<div class="targetBox2" date-tuan="' + i[j].TeamList[0].TuanNo + '" data-route="' + $("#" + i[j].LineCode).attr("route-data") + '"><div class="clear"><div class="tripstyle fl">' + $("#" + i[j].LineCode).attr("route-data") + "行程</div>",
                                e += '<p class="tripId fl" style="display:' + s + '">(' + i[j].TeamList[0].TuanNo.substr(6, 6) + ")</p></div>",
                                0 === i[j].TeamList[0].MinPrice)
                                    e += '<p class="jiage">成人价' + i[j].TeamList[0].Price + "</p>";
                                else {
                                    var l = i[j].TeamList[0].Price - i[j].TeamList[0].MinPrice;
                                    if (e += 0 === l ? '<p class="jiage"> <span>成人价' + i[j].TeamList[0].Price + "</span></p>" : '<p class="jiage">优惠价<span>¥' + i[j].TeamList[0].MinPrice + "</span> = 成人价" + i[j].TeamList[0].Price + " - 立减优惠<span>" + l + "</span></p>",
                                    "" !== i[j].TeamList[0].Preferential) {
                                        e += '<div class="xinxi">优惠信息</div>';
                                        var c = i[j].TeamList[0].Preferential.split("|");
                                        for (h = 0; h < c.length; h++)
                                            e += '<div class="li"><i>•</i>' + c[h] + "</div>"
                                    }
                                }
                                e += '<div class="data">' + i[j].Date + " 出发</div></div>"
                            }
                }
                e += '<div class="clear"></div></div>',
                $(this).append(e)
            }
        }),
        ShowDayDetails(),
        $(document).on("click", ".day-list li", function(t) {
            "" == $(this).find(".tuanno").html() || "" === $(this).find(".price").html() || $(this).hasClass("active") || $(this).hasClass("gray") || (fly_animation.call(this, t),
            $(this).addClass("active").siblings("li").removeClass("active"))
        }),
        $(".targetBox .targetBox2").on("click", function(t) {
            if ($(this).attr("date-tuan"))
                return t.stopPropagation(),
                fly_animation.call(this, t),
                !1
        })
    }
}
function ShowDayDetails() {
    $(".day-list").find("li").each(function() {
        var t = null
          , e = $(this);
        e.mouseenter(function() {
            t = setTimeout(function() {
                e.find(".targetBox").show()
            }, 100)
        }).mouseleave(function() {
            clearTimeout(t),
            e.find(".targetBox").hide()
        });
        var a = '[data-tuanno="' + ($(this).find(".tuanno").html() || $(this).attr("date-tuan")) + '"]';
        $(".selected_m .p" + a)
    }),
    stroke = $(".main2_right_m2.active").find(".main2_right_m3_m.stroke")
}
function fly_animation(t) {
    var e = $(this)
      , a = $(".main_right3 .select .select_left .selected").offset()
      , i = $('<div id="flyer" style="z-index:99999;"></div>')
      , n = $(this).find(".tuanno").html() || $(this).attr("date-tuan");
    if (void 0 == $(this).find(".tuanno").html())
        return !1;
    var r = function() {
        setTimeout(function() {
            $(".main_right3 .select .select_left .selected").addClass("active")
        }, 100),
        setTimeout(function() {
            $(".main_right3 .select .select_left .selected").removeClass("active")
        }, 300),
        setTimeout(function() {
            $(".main_right3 .select .select_left .selected").addClass("active")
        }, 500),
        setTimeout(function() {
            $(".main_right3 .select .select_left .selected").removeClass("active")
        }, 700);
        var t = '[data-tuanno="' + n + '"]';
        $(".selected_m .p" + t).addClass("active").siblings().removeClass("active"),
        ShowTourDetail($(".selected_m .p" + t));
        var a = $(".selected_m .p" + t).text();
        $(".selected").find(".li").html(a),
        RouteChange($(".selected_m .p" + t).attr("data-linecode")),
        e.hasClass("targetBox2") && (e.parent().parent().find(".price").text("¥" + $(".selected_m .p" + t).attr("data-price") + "起"),
        e.parent().parent().find(".tuanno").text($(".selected_m .p" + t).attr("data-tuanno"))),
        "0" == $(".selected_m .p" + t).attr("data-freenum") ? ($(".dwzx").show(),
        $(".submit").hide(),
        e.hasClass("targetBox2") && (e.parent().parent().find(".spare").text(StockShowReg($(".selected_m .p" + t).attr("data-freenum"))),
        e.parent().parent().find(".style").text(""),
        e.parents("li").addClass("gray").removeClass("active"))) : ($(".dwzx").hide(),
        $(".submit").show(),
        e.hasClass("targetBox2") && (e.parent().parent().find(".spare").text("余位:" + StockShowReg($(".selected_m .p" + t).attr("data-freenum"))),
        e.parent().parent().find(".style").text($(".selected_m .p" + t).attr("data-route") + "行程")),
        e.parents("li").addClass("active").removeClass("gray"))
    };
    0 < IEVersion() && IEVersion() < 10 ? r() : i.fly({
        start: {
            left: $(this).offset().left + 20,
            top: $(this).offset().top + 10
        },
        end: {
            left: a.left + 235,
            top: a.top,
            width: 10,
            height: 10
        },
        speed: 1.2,
        vertex_Rtop: 260,
        onEnd: function() {
            this.destroy(),
            r()
        }
    })
}
function ChooseTourList(t) {
    var e = new Array;
    for (i = 0; i < globalCalendarData.length; i++) {
        for (var a = globalCalendarData[i].DayList, n = 0; n < a.length; n++) {
            var r = a[n].Date.replace("-", "").replace("-", "")
              , o = $("#" + a[n].LineCode).attr("route-data");
            a[n].dataroute = r + o
        }
        if (a.sort(by("dataroute", by("ShortTuanNo"))),
        null !== a)
            for (j = 0; j < a.length; j++) {
                var s = new Object;
                s.TourDateText = a[j].Date;
                var l = a[j].TeamList;
                l.length > 0 && $.each(l, function(t, i) {
                    s.routeShortName = $("#" + a[j].LineCode).attr("route-data"),
                    s.MinPrice = i.MinPrice,
                    s.PayType = i.PayType,
                    s.TuanNo = i.TuanNo,
                    l.length > 1 ? s.Num = t + 1 : s.Num = 1;
                    var n = i.Price - i.MinPrice
                      , r = '<div class="p" data-price="' + i.MinPrice + '" data-preferential="' + i.Preferential + '" data-freenum="' + i.FreeNum + '" data-paytype="' + s.PayType + '" data-tuanno="' + s.TuanNo + '" data-teamid="' + i.TeamId + '" data-linecode="' + a[j].LineCode + '" data-route="' + s.routeShortName + '" data-supproductcode="' + i.SupProductCode + '" data-compcode="' + i.SaleCompCode + '" data-date="' + s.TourDateText + '">' + TourDateFormat(s.TourDateText) + "出发 - " + i.MinPrice + "/人 - " + (0 === n ? "" : "已减¥" + n + " - ") + s.routeShortName + "行程";
                    l[0].IsShowTuanNo && (r += " - 团" + s.TuanNo.substring(s.TuanNo.length - 6, s.TuanNo.length)),
                    r += "</div>",
                    e.push(r)
                })
            }
    }
    $.each(e, function(t, e) {
        $(".selected_m").append(e)
    }),
    $(".selected_m .p").on("click", function() {
        if (!$(this).hasClass("active")) {
            var t = $(this).text();
            $(this).parent().prev().html(t),
            $(this).parent().prev().attr("data-freenum", $(this).attr("data-freenum"));
            var e = $(this).attr("data-date").substring(0, $(this).attr("data-date").lastIndexOf("-"));
            $(".calendar").html(" "),
            calendar(e, ".calendar");
            var a = '[data-date="' + e + '"]'
              , i = $(".calendar_t_m").find("div" + a).attr("data-index");
            TourDateData(globalCalendarData, i),
            ShowTourDetail($(this)),
            $(this).addClass("active").siblings().removeClass("active"),
            globalCalendarData.length > 5 && mySwiper1.swipeTo(i, 1e3, !1),
            $(".calendar_t_m").find("div" + a).addClass("active").siblings().removeClass("active"),
            CheckStock(!1);
            var n = $(".day-list").find("li[data-time=" + parseISO8601($(this).attr("data-date")).Format("yyyy-M-d") + "]");
            $(n).addClass("active"),
            $(n).find(".price").text("¥" + $(this).attr("data-price") + "起"),
            "余位:0" === StockShowReg($(this).attr("data-freenum")) ? ($(n).find(".spare").text(StockShowReg($(this).attr("data-freenum"))),
            $(n).find(".style").text(""),
            $(".dwzx").show(),
            $(".submit").hide(),
            $(n).addClass("gray").removeClass("active")) : ($(n).find(".spare").text("余位:" + StockShowReg($(this).attr("data-freenum"))),
            $(n).find(".style").text($(this).attr("data-route") + "行程"),
            $(".dwzx").hide(),
            $(".submit").show()),
            $(n).find(".tuanno").attr("id", $(this).attr("data-tuanno")),
            $(n).find(".tuanno").html($(this).attr("data-tuanno")),
            RouteChange($(this).attr("data-linecode")),
            ShowDayDetails()
        }
    })
}
function getSaleNum() {
    var t = JSON.stringify({
        productcode: api.getUrlParam("prdouctId")
    });
    api.post("http://searchlogic.uzai.com/api/product/travelerscount", t, function(t) {
        null !== t && 200 === t.ErrorCode && $("#saleNum").html("累计销量：" + t.JsonResult)
    })
}
function ShowTourDetail(t) {
    if ("" === $(".main .title .word_icon").html() || void 0 === $(".main .title .word_icon").html() ? ($(".choose_route .word_icon").show(),
    $(".choose_route .word_icon").html(t.attr("data-paytype"))) : $(".choose_route .word_icon").hide(),
    $(".shortName").html(t.attr("data-route") + "行程"),
    "余位:0" != $(t).attr("data-freenum")) {
        var e = t.attr("data-preferential");
        if ("" !== e && void 0 !== e) {
            var a = t.attr("data-preferential").split("|")
              , i = "";
            $.each(a, function(t, e) {
                i += "<p>" + e + "</p>"
            }),
            $(".discount").html(i),
            $(".hau").show()
        } else
            $(".hau").hide()
    } else
        $(".hau").hide();
    $(".main_right3 .choose_route").show(),
    $(".main_right3").addClass("active")
}
function GetStock(t) {
    var e, a = $(".select_left .selected_m .active");
    e = "1" === $.trim($("#lineSource").val()) ? JSON.stringify({
        productCode: a.attr("data-supproductcode"),
        compCode: a.attr("data-compcode")
    }) : JSON.stringify({
        productCode: a.attr("data-tuanno"),
        compCode: ""
    }),
    api.post("http://tourlogic.uzai.com/api/product/CheckStock", e, function(e) {
        null !== e && t(200 === e.ErrorCode ? e.JsonResult : 0)
    })
}
function TourDateFormat(t) {
    var e = new Array("日","一","二","三","四","五","六")
      , a = new Date(t).getDay();
    return t.substring(t.indexOf("-") + 1) + "(周" + e[a] + ")"
}
function parseISO8601(t) {
    var e, a = new Date(NaN), i = /^\s*(\d{4})-(\d\d)-(\d\d)\s*$/.exec(t);
    return i && (e = +i[2],
    a.setFullYear(i[1], e - 1, i[3]),
    e !== a.getMonth() + 1 && a.setTime(NaN)),
    a
}
function activityDetailsHeightInit() {
    var t = $(".main").eq(0).outerHeight() + $(".main").eq(0).offset().top - $(".main_right5_m_m").offset().top - 50;
    $(".main_right5_m_m").height(t),
    $("#activityContent").height() < t ? $(".main_right5_m .more").hide() : ($(".main_right5_m .more").removeClass("a").find("span").text("更多").end().find("i").addClass("icon-zhankai").removeClass("icon-shouqi"),
    $(".main_right5_m").removeClass("bor1"),
    $(".main_right5_m .more").off().on("click", function() {
        $(this).hasClass("a") ? ($(this).find("span").text("更多"),
        $(this).find("i").addClass("icon-zhankai").removeClass("icon-shouqi"),
        $(this).removeClass("a"),
        $(".main_right5_m_m").css("height", t),
        $(".main_right5_m").removeClass("bor1")) : ($(this).find("span").text("收起"),
        $(this).find("i").removeClass("icon-zhankai").addClass("icon-shouqi"),
        $(this).addClass("a"),
        $(this).next().css("height", "auto"),
        $(".main_right5_m").addClass("bor1"))
    }))
}
function quickLoginCallBack() {
    var t = $(".collection");
    t.hasClass("active") ? CollectProduct(!0, function(e) {
        2 === e ? (t.removeClass("active"),
        t.find("span").text("收藏")) : alert("取消收藏失败")
    }) : CollectProduct(!1, function(e) {
        e > 0 ? (t.addClass("active"),
        t.find("span").text("已收藏"),
        $("#collectionId").val(e)) : alert("收藏失败")
    }),
    location.reload()
}
function IEVersion() {
    var t = navigator.userAgent
      , e = t.indexOf("compatible") > -1 && t.indexOf("MSIE") > -1
      , a = t.indexOf("Edge") > -1 && !e
      , i = t.indexOf("Trident") > -1 && t.indexOf("rv:11.0") > -1;
    if (e) {
        new RegExp("MSIE (\\d+\\.\\d+);").test(t);
        var n = parseFloat(RegExp.$1);
        return 7 == n ? 7 : 8 == n ? 8 : 9 == n ? 9 : 10 == n ? 10 : 6
    }
    return a ? "edge" : i ? 11 : -1
}
function getNow(t) {
    return t < 10 ? "0" + t : t
}
function GetDateNow() {
    var t = new Date
      , e = t.getFullYear()
      , a = t.getMonth() + 1
      , i = t.getDate()
      , n = t.getHours()
      , r = t.getMinutes()
      , o = t.getSeconds();
    return e + "-" + getNow(a) + "-" + getNow(i) + " " + getNow(n) + ":" + getNow(r) + ":" + getNow(o)
}
function saveBrowsingHistory() {
    var t = getCookie("history_product")
      , e = []
      , a = {
        UserID: 0,
        ProductID: api.getUrlParam("prdouctId"),
        ProductName: $(".title").text().replace("即时付款", "").replace("二次确认", ""),
        ProductPrice: $("#productprice").val(),
        City: getCookie("_city_id"),
        CityName: $("#startcity").val(),
        ScanDate: GetDateNow(),
        ProductPicURL: $("#productimgurl").val(),
        ProductTypeName: $("#producttype").val(),
        ProductURL: location.href
    };
    t && (e = JSON.parse(t)),
    e.push(a),
    api.loginInfo(function(t) {
        if ("1" == t.isLogin && e) {
            var a = JSON.stringify({
                userid: api.getCookie("user"),
                productlist: e
            });
            api.post("http://tourlogic.uzai.com/api/product/AddBrowserRecord", a, function(t) {
                null !== t && (200 === t.ErrorCode ? console.log("插入浏览记录成功~") : console.log("插入浏览记录失败~"))
            })
        }
    })
}
var stroke, globalCalendarData, date = new Date, year = date.getFullYear(), mon = date.getMonth() + 1, mySwiper1 = "";
$(function() {
    api.urlReg = "/tour/{prdouctId}.html",
    calendar(year + "-" + mon, ".calendar"),
    $(document).on("click", ".main2_right_m2_nav .curr li", function() {
        var t = $(this).index();
        $("html,body").stop().animate({
            scrollTop: $(this).parents(".u_route").find(".main2_right_m2.active").find(".trip_nav_m").eq(t).offset().top - 80
        }, 200)
    }).on("click", function() {
        $(".selected_m").hide(),
        $(".trip_nav").removeClass("active")
    }),
    $(".selected .li").click(function() {
        return $(this).next().show(),
        !1
    }),
    $("#adultNum").val("1"),
    $("#childNum").val("0"),
    $(".num .add").click(function() {
        var t = 1 * $(this).prev().val() + 1;
        CheckStock(!0) && $(this).prev().val(t)
    }),
    $(".num .reduce").click(function() {
        var t = 1 * $(this).next().val() - 1;
        "adultNum" === $(this).next().attr("id") ? t <= 0 && (t = 1) : t <= 0 && (t = 0),
        $(this).next().val(t),
        CheckStock()
    }),
    $(".collection").click(function() {
        "" !== api.getCookie("user") && void 0 !== api.getCookie("user") ? api.loginInfo(function(t) {
            if (1 === t.isLogin) {
                var e = $(".collection");
                e.hasClass("active") ? CollectProduct(!0, function(t) {
                    2 === t ? (e.removeClass("active"),
                    e.find("span").text("收藏")) : alert("取消收藏失败")
                }) : CollectProduct(!1, function(t) {
                    t > 0 ? (e.addClass("active"),
                    e.find("span").text("已收藏"),
                    $("#collectionId").val(t)) : alert("收藏失败")
                })
            } else
                showIframe("https://u.uzai.com/User/QuickLogin", 490, 300)
        }) : showIframe("https://u.uzai.com/User/QuickLogin", 490, 300)
    }),
    IsCollectProduct(),
    $(".main2_right_n1 .li").mouseover(function() {
        $(this).addClass("active").siblings().removeClass("active");
        var t = $(this).index();
        $(".main2_right_m1_m").eq(t).show().siblings().hide()
    }),
    $(".main2_right_m1_m .more").click(function() {
        $(this).hasClass("lw") ? $(this).removeClass("lw").html('查看更多 <i class="iconfont icon-zhankai"></i>').siblings(".main2_right_m1_li.hidden").hide() : $(this).addClass("lw").html('收起 <i class="iconfont icon-shouqi"></i>').siblings(".main2_right_m1_li.hidden").show()
    });
    var t = $(".nav_li").offset().top
      , e = $(".main2_right_m2.active .main2_right_m2_title.trip_nav_m").eq(0).offset().top;
    stroke = $(".main2_right_m2.active").find(".main2_right_m3_m.stroke"),
    $(window).scroll(function() {
        $(window).scrollTop() > t ? ($(".nav_li").addClass("nav_li_fiexd"),
        $(".main2").css("paddingTop", 40),
        $(".main2 ul").each(function(t, e) {
            $(window).scrollTop() + 50 >= $(e).offset().top && $(".nav_left .li").eq(t).addClass("active").siblings().removeClass("active")
        })) : ($(".nav_li").removeClass("nav_li_fiexd"),
        $(".main2").css("paddingTop", 0)),
        $(window).scrollTop() + 80 >= e ? ($(".main2_right_m2_nav").addClass("fiexd").show(),
        $(".main2_right_m2.active").find(".trip_nav_m").each(function(t, e) {
            $(window).scrollTop() + 80 >= $(e).offset().top && $(".curr li").eq(t).addClass("active").siblings().removeClass("active")
        })) : $(".main2_right_m2_nav").removeClass("fiexd").hide(),
        $(window).scrollTop() + 80 >= stroke.offset().top && $(window).scrollTop() <= stroke.offset().top + stroke.height() ? ($(".trip_m").fadeIn(),
        $(".main2_right_m2.active").find(".stroke .main2_right_m3_m1").each(function(t, e) {
            $(window).scrollTop() + 82 >= $(e).offset().top && $(".main2_right_m2.active").find(".trip_m .li").eq(t).addClass("active").siblings().removeClass("active")
        })) : $(".trip_m").fadeOut()
    }),
    $(".main2_right_n2 .li").mouseover(function() {
        $(this).addClass("active").siblings().removeClass("active");
        var t = $(this).index(".main2_right_n2 .li");
        $(".main2_right_m2").eq(t).addClass("active").siblings(".main2_right_m2").removeClass("active");
        var e = $(this).attr("data-linecode");
        $(".main2_right_n2_right").find("a").each(function() {
            $(this).attr("href", "http://tour.uzai.com/print/" + api.getUrlParam("prdouctId") + "/" + e)
        }),
        RouteChange($(this).attr("data-linecode"))
    }),
    $(".trip_nav .li1").click(function() {
        $(".trip_nav .li").prepend($(this).find("span")),
        $(this).prepend($(".trip_nav .li").find("span").eq(1)),
        RouteChange($(".trip_nav .li").find("span").eq(0).attr("id")),
        $("html,body").animate({
            scrollTop: $(".main2 ul.u_route").offset().top - 40
        }),
        $(this).parents(".trip_nav").removeClass("active")
    }),
    $(".nav_left .li").click(function() {
        var t = $(this).index();
        $("html,body").animate({
            scrollTop: $(".main2 ul").eq(t).offset().top - 40
        })
    }),
    $(".trip_nav .li").click(function(t) {
        t.stopPropagation(),
        $(".trip_nav").hasClass("active") ? $(".trip_nav").removeClass("active") : $(".trip_nav").addClass("active")
    }),
    $(".trip_m .li").on("click", function() {
        var t = $(this).index()
          , e = $(".main2_right_m2.active").find(".stroke .main2_right_m3_m1").eq(t).offset().top;
        $("html,body").animate({
            scrollTop: e - 80
        })
    }),
    $(".main_left_rotater1").click(function() {
        $(this).addClass("active").siblings().removeClass("active");
        var t = $(this).find(".img").attr("src").split("?");
        2 === t.length && $(".main_left_rotatel img").attr("src", t[0] + "?imageView2/1/w/550/h/413/format/jpg"),
        $(this).find("img").addClass("active").removeClass("hide")
    }),
    $(".main2_right_m2_m p b").click(function() {
        $(this).hasClass("a") ? ($(this).removeClass("a").html("展开"),
        $(this).parent().css("height", "20px"),
        $(this).parent().css("overflow", "hidden")) : ($(this).addClass("a").html("收起"),
        $(this).parent().css("height", "auto"))
    }),
    $(".main_right3 .select_left .tirp b").click(function() {
        $("html,body").animate({
            scrollTop: $(".main2 ul.u_route").offset().top
        })
    }),
    $(".main_right2 .see").click(function() {
        $("html,body").animate({
            scrollTop: $(".nav_li").offset().top
        })
    }),
    CalendarData(),
    getProductInfo(),
    $("img.lazy").lazyload(),
    $(".submit").click(function() {
        var t = $(".selected").find(".li").text().split("(")[0];
        CheckStock(!1) && GetStock(function(t) {
            var e = parseInt($("#adultNum").val()) + parseInt($("#childNum").val());
            if (parseInt(t) < e)
                return $(".num .lack").css("display", "inline"),
                !1;
            $(".num .lack").css("display", "none");
            var a = $("#adultNum").val()
              , i = $("#childNum").val()
              , n = $(".select_left .selected_m .active");
            location.href = "//tourbuy.uzai.com/booking/" + n.attr("data-date") + "/" + n.attr("data-tuanno") + "/" + n.attr("data-teamid") + "/" + a + "/" + i + "/" + $("#lineSource").val() + "/" + api.getUrlParam("prdouctId") + ".html"
        })
    }),
    GetQrCode(),
    $(".nav_li .bot").click(function() {
        $(window).scrollTop(200)
    }),
    getSaleNum(),
    activityDetailsHeightInit(),
    $(".main_right5_m_m img").remove(),
    saveBrowsingHistory()
});
var by = function(t, e) {
    return function(a, i) {
        var n, r;
        if (a && i && "object" == typeof a && "object" == typeof i)
            return n = a[t],
            r = i[t],
            n === r ? "function" == typeof e ? e(a, i) : 0 : typeof n == typeof r ? n < r ? -1 : 1 : typeof n < typeof r ? -1 : 1;
        thro("error")
    }
};
Date.prototype.Format = function(t) {
    var e = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        S: this.getMilliseconds()
    };
    /(y+)/.test(t) && (t = t.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)));
    for (var a in e)
        new RegExp("(" + a + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? e[a] : ("00" + e[a]).substr(("" + e[a]).length)));
    return t
}
,
jQuery.fn.sortElements = function() {
    var t = [].sort;
    return function(e, a) {
        a = a || function() {
            return this
        }
        ;
        var i = this.map(function() {
            var t = a.call(this)
              , e = t.parentNode
              , i = e.insertBefore(document.createTextNode(""), t.nextSibling);
            return function() {
                if (e === this)
                    throw new Error("You can not sort elementsif any one is a descendant of another.");
                e.insertBefore(this, i),
                e.removeChild(i)
            }
        });
        return t.call(this, e).each(function(t) {
            i[t].call(a.call(this))
        })
    }
}();
